package com.example.myapplication2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class SupplierActivity extends AppCompatActivity {

    private TextView textView3;
    private RadioButton radioButton5;
    private RadioButton radioButton6;
    private RadioButton radioButton7;
    private RadioButton radioButton8;
    private Button button2;
    private RadioGroup radioGroup;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_supplier);
        initView();
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            int radBtnID = radioGroup.getCheckedRadioButtonId();
            if (radBtnID!=-1){
              RadioButton radBut = findViewById(radBtnID);
                Intent intent = new Intent();
                intent.putExtra("sup",radBut.getText().toString());
                setResult(RESULT_OK,intent);
                finish();
            }

            }
        });

    }

    private void initView() {
        textView3 = (TextView) findViewById(R.id.textView3);
        radioButton5 = (RadioButton) findViewById(R.id.radioButton5);
        radioButton6 = (RadioButton) findViewById(R.id.radioButton6);
        radioButton7 = (RadioButton) findViewById(R.id.radioButton7);
        radioButton8 = (RadioButton) findViewById(R.id.radioButton8);
        button2 = (Button) findViewById(R.id.button2);
        radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    }
}